//package cn.bonoon.kernel.util;
//
//import java.awt.image.BufferedImage;
//import java.io.InputStream;
//import java.io.OutputStream;
//
//import javax.imageio.ImageIO;
//
//import com.google.zxing.BarcodeFormat;
//import com.google.zxing.BinaryBitmap;
//import com.google.zxing.LuminanceSource;
//import com.google.zxing.MultiFormatReader;
//import com.google.zxing.MultiFormatWriter;
//import com.google.zxing.Result;
//import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
//import com.google.zxing.client.j2se.MatrixToImageWriter;
//import com.google.zxing.common.BitMatrix;
//import com.google.zxing.common.HybridBinarizer;
//
///**
// * 条形码的生成辅助类
// * 
// * @author jackson
// * 
// */
//public final class BarcodeHelper extends BaseCode{
//	private BarcodeHelper(){
//		super(BarcodeFormat.EAN_13, 25, DEFAULT_WIDTH);
//	}
//	public final static BarcodeHelper getHelper(){
//		return new BarcodeHelper();
//	}
//	private static final int DEFAULT_WIDTH = 3 + // start guard
//			(7 * 6) + // left bars
//			5 + // middle guard
//			(7 * 6) + // right bars
//			3; // end guard
//
//
//	public void encode(String contents, int width, int height,
//			OutputStream stream) {
//		try {
//			BitMatrix bitMatrix = new MultiFormatWriter().encode(contents,
//					barcodeFormat, Math.max(minWidth, width),
//					Math.max(minHeight, height), null);
//
//			MatrixToImageWriter.writeToStream(bitMatrix, formatName, stream);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}
//	
//
//	public String decode(InputStream input) {
//		BufferedImage image = null;
//		Result result = null;
//		try {
//			image = ImageIO.read(input);
//			if (image == null) {
//				throw new NullPointerException("条形码不存在!");
//			}
//			LuminanceSource source = new BufferedImageLuminanceSource(image);
//			BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
//
//			result = new MultiFormatReader().decode(bitmap, null);
//			return result.getText();
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		return null;
//	}
//}
